<template>
    <view class="container">
        <oreder-header @searchFn="searchFn" @doFilter="doFilter"></oreder-header>
        <view class="main">
            <order-list v-if="loadOk" ref="productList_1" :height="listHeight" :requestData="requestData"></order-list>
        </view>
    </view>
</template>

<script>
import { mapGetters } from "vuex"
import orederHeader from "@/pages_supplier/components/accountBuy/order-header.vue"
import orderList from "@/pages_supplier/components/accountBuy/order-list.vue"
import { getElementHeight } from "@/uni-sub-base/utils/elementUtil.js"
export default {
    components: {
        orederHeader,
        orderList,
    },
    data() {
        return {
            optEmpty: {
                icon: "/static/img/empty.png", // 图标路径 (建议放入static目录, 如 /static/img/mescroll-empty.png )
                tip: "~ 暂无数据 ~", // 空提示
            },
            isloadding: false,
            listHeight: "", //list所需高度
            loadOk: false,
            searchKey: "",
            requestData: {
                state: -1,
                createType: -1,
                searchKey: "",
                startTime: "",
                endTime: "",
            },
        }
    },
    watch: {
        //监听更新
        getUpOrderAccountView(e) {
            this.refresh()
        },
    },
    computed: {
        ...mapGetters(["getUpOrderAccountView"]),
    },
    onLoad(e) {
        if (e.tabIndex) {
            this.tabIndex = e.tabIndex
        }
    },
    onShow() {},
    mounted() {
        this.getListHeight()
    },
    methods: {
        getListHeight(element) {
            //获取商品高度
            getElementHeight(this, ".main", (e) => {
                this.listHeight = e - 60 + "px"
                this.loadOk = true
            })
        },
        //搜索
        searchFn(searchKey) {
            this.requestData.searchKey = searchKey
            this.refresh()
        },
        //筛选
        doFilter(data) {
            console.log(data)
            this.requestData.startTime = data.startDate ? data.startDate + " 00:00:00" : ""
            this.requestData.endTime = data.endDate ? data.endDate + " 23:59:59" : ""
            this.requestData.state = data.state ? data.state : ""
            this.refresh()
        },
        refresh() {
            this.$refs.productList_1.refresh(this.requestData)
        },
    },
}
</script>

<style lang="scss" scoped>
.container {
    display: flex;
    flex-direction: column;
}
</style>
